var singleNumber = function (nums) {
  let num = new Array();
  nums.sort(cmp);
  for (let i = 0; i <= nums[nums.length - 1]; i++) {
    num[i] = 0;
  }
  for (let i of nums) {
    num[i]++;
    console.log(num);
  }
  for (let i in num) {
    if (num[i] == 1) {
      return i;
    }
  }
};
function cmp(val, val2) {
  return val - val2;
}
console.log(singleNumber([2,2,1]));
